//
//  BMItemView.m
//  Rail
//
//  Created by hychen on 2018/3/5.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import "BMItemView.h"

@implementation BMItemModel
MJCodingImplementation
@end

@interface BMItemView ()
@end
@implementation BMItemView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self addTapGestureWithTarget:self action:@selector(itemClick)];
        
        self.titleLabel = [UILabel labelWithText:@"" textColor:Color_Hex(0x565656) font:[UIFont systemFontOfSize:12.f]];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.titleLabel];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(7);
            make.left.right.equalTo(self);
        }];
        self.contentLabel = [UILabel labelWithText:@"" textColor:Color_Hex(0x565656) font:[UIFont systemFontOfSize:12.f]];
        self.contentLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.contentLabel];
        [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self);
            make.bottom.mas_equalTo(-7);
        }];
    }
    return self;
}

- (void)itemClick {
    if (self.BlockClickItem) {
        self.BlockClickItem(self.model,self.index);
    }
}

- (void)setTitle:(NSString *)title content:(NSString *)content {
    self.titleLabel.text = title;
    self.contentLabel.text = content;
}

- (void)setModel:(BMItemModel *)model {
    _model = model;
    [self setTitle:model.title?:@"" content:model.content?:@""];
}
@end
